// 根据接口封装了请求函数
import request from '@/utils/request'
/**
 * 封装获取企业部门列表
*/

export function reqGetDepartments() {
  return request({
    url: '/company/department'
  })
}

/**
 * 根据id删除部门
 * **/
export function reqDelDepartments(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'delete'
  })
}

/**
 * 新增部门
 * @param {*}
 * @return {*}
 * **/
export function reqAddDepartments(data) {
  return request({
    url: '/company/department',
    method: 'post',
    data
  })
}

/**
 * 获取某部门详细信息
 * @param {*}
 * @return {*}
 * **/
export function reqGetDepartDetail(id) {
  return request({
    url: `/company/department/${id}`
  })
}

/**
 * 编辑部门
 * @param {object} data
 * @param {string} data.code
 * @param {string} data.companyId
 * @param {string} data.createTime
 * @param {string} data.id
 * @param {string} data.introduce
 * @param {string} data.manager
 * @param {string} data.managerId
 * @param {string} data.name
 * @param {string} data.pid
 * @return {*}
 * **/
export function reqUpdateDepartments(data) {
  return request({
    url: `/company/department/${data.id}`,
    method: 'put',
    data
  })
}

// 根据 id 查询企业
export const reqGetCompanyById = (id) => {
  return request({
    method: 'get',
    url: `/company/${id}`
  })
}
